<html>
<head><meta charset="utf-8"><title>glob pattern in workspace.exclude · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html">glob pattern in workspace.exclude</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226876929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226876929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226876929">(Feb 18 2021 at 20:42)</a>:</h4>
<p>Is there a technical reason why when specifying a <code>workspace</code> in the <code>Cargo.toml</code> glob patterns are allowed and recognized in the <code>members</code> list, but not in the <code>exclude</code> list? <a href="https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspace-section">Documentation</a></p>
<p>We currently <a href="#narrow/stream/257328-clippy/topic/workspaces.20changes.20broke.20lintcheck/near/226874373">try to use this in Clippy</a></p>



<a name="226879900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226879900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226879900">(Feb 18 2021 at 21:01)</a>:</h4>
<p><span class="user-mention" data-user-id="264664">@flip1995</span> I think it's just not implemented.  See <a href="https://github.com/rust-lang/cargo/issues/6009">https://github.com/rust-lang/cargo/issues/6009</a>.  Its not clear if it should use glob or gitignore, and what the migration strategy should be, but it definitely would be nice to improve that.</p>



<a name="226881655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226881655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226881655">(Feb 18 2021 at 21:13)</a>:</h4>
<p>Thanks! Is the glob syntax for workspace members stable?</p>
<p>Just from a gut feeling I would go for glob patterns. <code>gitignore</code> is really good for fine grained management of files. But you don't need such a find grained management for workspace members, because you just deal with directories. So glob patterns would be fine. Also  since members already use glob patterns I think it stays consistent with features people already use. All that is just an uninformed feeling though.</p>



<a name="226882886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226882886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226882886">(Feb 18 2021 at 21:21)</a>:</h4>
<p><span class="user-mention" data-user-id="264664">@flip1995</span> I can <em>imagine</em> wanting to do "everything in X except for X/Y", but at the same time, members use globs so consistency seems preferable to capability here.</p>



<a name="226883115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226883115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226883115">(Feb 18 2021 at 21:22)</a>:</h4>
<p>But couldn't you also do this with glob patterns?</p>
<div class="codehilite"><pre><span></span><code>members = [&quot;X/**&quot;]
exclude = [&quot;X/Y&quot;]
</code></pre></div>
<p>At least the current documentations suggests that you can do this.</p>



<a name="226883926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226883926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226883926">(Feb 18 2021 at 21:29)</a>:</h4>
<p><span class="user-mention" data-user-id="264664">@flip1995</span> You could, but then you couldn't do "include everything in X, except don't include X/Y, but do include X/Y/Z". Which is increasingly improbable. ;)</p>



<a name="226884122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226884122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226884122">(Feb 18 2021 at 21:30)</a>:</h4>
<p>I think it <em>might</em> make sense to add support for gitignore-style patterns in members (and anywhere else we support lists of files), which would make it unnecessary to use "exclude" at all, but I also think that it's not especially important and might not be worth the churn for the rare case it would help.</p>



<a name="226884196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226884196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226884196">(Feb 18 2021 at 21:31)</a>:</h4>
<p>As a terrible abuse, I've done somdthing like <code>members = ["**/src/.."]</code> before to avoid limitations of workspace.exclude.</p>



<a name="226884919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226884919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226884919">(Feb 18 2021 at 21:36)</a>:</h4>
<p>Oh yeah, that is indeed not possible with glob patterns. </p>
<p>So would a implementation plan make sense, where for now glob patterns are implemented for <code>exclude</code> and leave open the possibility to later move to gitignore style?</p>



<a name="226887195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226887195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226887195">(Feb 18 2021 at 21:54)</a>:</h4>
<blockquote>
<p>Thanks! Is the glob syntax for workspace members stable?</p>
</blockquote>
<p>Yea, it is documented, and has been like that for a long while.</p>
<blockquote>
<p>So would a implementation plan make sense, where for now glob patterns are implemented for exclude and leave open the possibility to later move to gitignore style?</p>
</blockquote>
<p>I don't have a strong preference.   Whatever approach, it needs to somehow deal with backwards compatibility with the current starts_with behavior.  It took 2 years to transition package include/exclude (<a href="https://github.com/rust-lang/cargo/issues/4268">#4268</a>) to gitignore.  I don't know how that would work here.</p>
<p>It does seem a little strange to me to have package include/exclude use gitignore and workspace to use globs, but it probably doesn't matter too much.  We could add globs to <code>exclude</code> and then at a later date consider transitioning both include/exclude to gitignore, since that is a little trickier.  <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="226889751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226889751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226889751">(Feb 18 2021 at 22:06)</a>:</h4>
<p>So the best case would be to have gitignore support for workspaces.</p>
<p>About the backwards compat: Would it make sense to just include this in the 2021 edition and deprecate the <code>starts_with</code> way?</p>



<a name="226898993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226898993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226898993">(Feb 18 2021 at 23:21)</a>:</h4>
<p>I don't know if the <code>starts_with</code> behavior is fundamentally incompatible with globbing.  I think it should be safe to just add globbing to it, but I haven't thought about it too much.</p>



<a name="226909321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226909321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226909321">(Feb 19 2021 at 01:29)</a>:</h4>
<p>I think the main limitation would be handling of filenames that start with <code>!</code>.</p>



<a name="226909334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/glob%20pattern%20in%20workspace.exclude/near/226909334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/glob.20pattern.20in.20workspace.2Eexclude.html#226909334">(Feb 19 2021 at 01:29)</a>:</h4>
<p>Otherwise they should be similar.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>